﻿<cfmodule template="../../tag/layout.cfm">
<form method="post" class="form">
  <fieldset>
    <legend>用户基本信息</legend>
    <table class="table" width="100%">
      <tbody>
        <tr>
          <th>编号</th>
          <td><input name="id" readonly /></td>
          <th>&nbsp;</th>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <th>角色姓名</th>
          <td><input name="name" class="easyui-validatebox" data-options="required:true"/></td>
          <th>登陆名称</th>
          <td><input name="loginname" class="easyui-validatebox" data-options="required:true" /></td>
        </tr>
        <tr>
          <th>年龄</th>
          <td><input name="seq" class="easyui-validatebox easyui-numberspinner"  data-options="min:0,max:100,required:true" value="20"  style="width:50px;" /></td>
          <th>性别</th>
          <td>
          	<select class="easyui-combobox" name="sex" data-options="panelHeight:'auto',editable:false" style="width: 155px;">
					<option value="1">男</option>
					<option value="0">女</option>
			</select>
          	</td>
        </tr>
        <tr>
          <th>密码</th>
          <td><input name="pwd" type="password" class="easyui-validatebox" data-options="required:true" /></td>
          <th>&nbsp;</th>
          <td>&nbsp;</td>
        </tr>
      </tbody>
    </table>
  </fieldset>
</form>

</cfmodule>
<cfscript>
	if( structKeyExists(rc, "id")  && rc.id > 0 ){
		id = rc.id;
	}else{
		id = 0;
	}
</cfscript>
<script  src="../../assets/js/jquery.json.js" >
	
</script>

<script type="text/javascript">
	var closeDialog = function($dialog) {
		$dialog.dialog('destroy');
	}
	
	var submitNow = function($dialog, $grid, $pjq) {
		var url;
		if ($(':input[name="id"]').val().length > 0) {
			url = '?action=user.update'; //更新操作
		} else {
			url = '?action=user.save';	//新增操作
		}
		$.post(url, fw.serializeObject($('form')), function(result) {
			if (result) {
				$grid.datagrid('reload');
				$dialog.dialog('destroy');
			}
		}, 'json');
	};
	
	var submitForm = function($dialog, $grid, $pjq) {
		if ($('form').form('validate')) {
			submitNow($dialog, $grid, $pjq);
		}
	};

	//加载数据，初始进度条
	parent.$.messager.progress({
		text : '数据加载中....'
	});

	$(function(){
		$.ajax({
		    type: "POST",
		    url: "?action=user.get",
		    data: {
		        id:<cfoutput>#id#</cfoutput>
		    }
		}).done(function(result) {
			$('form').form('load', result); 
			parent.$.messager.progress('close');
		}, 'json');
	})
</script>	 
